<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script>
			function show(){
				var _did=did.value;
				
				var xhr=new XMLHttpRequest();
				xhr.open("get",`/order_detail/v1/detail_search/${_did}`,true);
				xhr.send();
				xhr.onreadystatechange=function(){
					if(xhr.readyState==4 && xhr.status==200){
						var r=xhr.responseText;
						//把json串转换成js对象-----json解析
						var arr=JSON.parse(r);
						var strHTML=`
						<table border="1" bordercolor="purple" width="800" align="center">
							<tr>
								<th>编号</th>
								<th>订单id</th>
								<th>商品id</th>
								<th>数量</th>
							</tr>
						`;
						for(var i=0;i<arr.length;i++){
						strHTML+=`
						<tr>
							<td>${arr[i].did}</td>
							<td>${arr[i].order_id}</td>
							<td>${arr[i].product_id}</td>
							<td>${arr[i].count}</td>
						</tr>
						`
						}
						strHTML+="</table>";
						d1.innerHTML=strHTML;
						}
						if(r==0){
							d1.innerHTML="查无此人"
						}
						
					}
				}
		</script>
	</head>
	<body>
		<input type="text" id="did">编号<br>
		<button onclick="show()">查询</button>
		<div id="d1"></div>
	</body>
</html>
